import fs from 'fs'
import {execa} from 'execa'
const dirs = fs.readdirSync("packages").filter(p=>{
  if (!fs.statSync(`packages/${p}`).isDirectory()) {
    return false
  }
  return true
})
async function build(target){
  // -c 执行rollup配置，环境变量
  await execa("rollup",["-c","--environment",`TARGET:${target}`],
  {stdio:"inherit"})
  
}
async function runParaller(dirs,itemfn){
  let result= [];
  for (let item of dirs) {
    result.push(itemfn(item));
  }
  return Promise.all(result);
}
runParaller(dirs,build).then(()=>{
  
})